Dateadd And Convert Date Problem
Does any one know how I can use DATEADD and COVERT in the same select statement for retrieving data from a smalldatetime field?
I want to retrieve a date, add a year to it, then convert it to dd/mm/yyyy format without the time showing. It works seperatly EG:
convert date - SELECT adId, CONVERT(CHAR(11),datefrom,103) AS datefrom1 FROM ...
Add date - SELECT adId, DATEADD(year, 1, datefrom) AS dateto FROM....
How do you combine the 2 statements? I have been going slowly mad trying to figure this out
I’m using ASP3.JS and MS-SQL db
View Replies
ADVERTISEMENT
I have built an online booking system for a hotel and all is working fine except for the fact that the ‘From’ and ‘To’ dates are saved in the MS Access database in US format. The user selects from a date picker pop, which places the in the textfield as English format e.g. 02/12/2007.
However when I try and save this value into the date column in my DB I obviously receive an error because the formats are different. Please could someone advise me on the best way to convert an English date to a US in order to insert this into the DB using ASP & MS Access.
At the moment I am using plain text as the column type, but this is not ideal as I want to start to run queries against the 2 dates.
View Replies
View Related
I'm using Access database. There is a date field with the medium format (dd-mon-yy).
Through ASP Form, I enter a date which is in mm/dd/yyyy, How do I convert this in to medium date.
View Replies
View Related
I am trying to compare a variable with a db plain text field as follows:
access db has field named HFRNUM as text .... ex: 12182003-A
I create a variable in vb as follows:
Dim hfr_today
HFR_Today = (Month(DATE)) & (DAY(DATE)) & (YEAR(DATE)) & "-A"
Unfortuantely, I think the HFR_Today var is not text and when I look for a record that is LIKE or = the var, it returns blank.
I display my variable and see 12182003-A, yet it does not find the record that matches (except data type perhaps?) Is my variable of a different data type, and if so, how can I make it plain text?
View Replies
View Related
Can anyone please tell me is there any method to convert the week to the date?? For example If the week is 6 then we can get the date where the date is between '2/1/2004'
and '2/7/2004'
View Replies
View Related
I have a form which is posting a user entered date to an asp page. The date is then used in a SQL string.
The format of the date is received as dd/mm/yyyy, with the user typing the '/' as well
how can I convert it to yyyy-mm-dd
----------------
I have tried this, but I think I need to strip out the '/' ??, as it is
not working
D1 = cdate(request.form("date"))
strDay = Day(D1)
strMonth = Month(D1)
strYear = Year(D1)
NewstrDate = strYear & "-" & strMonth & "-" & strDay
View Replies
View Related
I've got an ASP script connected to a db table with a datetime field which is filled mannually for each record. When I want to select only those records with a date greater than todays date using this sql query:
Select * from fixtures where home_team_code = '" & idno & "' or away_team_code = '" & idno & "' and game_date > '" & today & "' order by game_date asc
it returns all records rather than only records with a date in the future. Is this something to do with the fact that i'm comparing a string to a datetime?? Can I use a VBScript function to make the string comparable to datetime?
View Replies
View Related
I ve a problem regarding the date format. i m using access as a database and want to insert date in dd mm yyyy format but wen the date is less than 12 then it converts it into mm dd yyyy and store it like that. this is really creating a problem .
View Replies
View Related
I've got a shipping date field which I read from a database, I want to bring up two weeks of data based on the shipping date.
For example, If the weekday was Tuesday id like to convert the weekday to a date then bring up the results based on the next upcoming Tuesday and all the orders that are inside a future 2 weeks shipping date, as above. How can I convert a weekday to a date, is this possible?
View Replies
View Related
I want insert string date from web form into oracle DB, using following to get date value:
sUpdateTime = Request.Form("date")
the date format the user enetr on the web is mm/dd/yyyy: h24:mi:ss (e.g. 04/13/2005 13:35:01). UpdateTime datatype in Oracle is date, so when insert sUpdateTime into DB, using following code got problem, I knew using To_Date (...) in the insert sql, but don't know the syntax.
strSQL = "Insert into table1 (UpdateTime)"
strSQL = strSQL & " values (?)"
oCmd.CommandText = strSQL
oCmd.Parameters.Refresh
oCmd.Parameters(0) = sUpdatetime
oCmd.Execute
View Replies
View Related
I try to convert a string in to date format, but I didn't succeed until now.
I get a specified date in this form:
date = "20060808"
In the first step I convert the date to a valid date-format:
convdate = right (z,2)&"-"& mid(z,5,2)& "-" & left(z,4)
'looks like this now: "08-08-2006"
Now I want to put this value in a date-format to adding and substracting a days much easier for me.
test = (date)convdate
test = test+15
The problem is that I don't know how to convert into date format.
View Replies
View Related
I need to convert a string that I pull out from a XML-feed to a valid date format. The date format in the XML-feed is like this:
2005-01-12T10:06:42.8130000
I want to change convert to a date type, in
this format:12.01.2005 12:06:42
(mm.dd.yyy tt:mm:ss)
View Replies
View Related
having issues submitting dates to a mysql db, ive converted the database from access to mysql and im having issues submitting dates. this is what i have when submitting to access
Code:
View Replies
View Related
I'm trying to compare two dates, All I need to see is if the first date is greater than the second date.
I'm fimiliar with how the DateAdd works, I use it often in my SQL Stored Procs, but for ASP it doesnt want to return a value Here's an piece of the code:
If DateAdd(d,DateDiff(d,0,BookingDate),0) > DateAdd(d,DateDiff(d,0,EndDate),0) Then
Flag = 0
Else...
I've also tried just printing out the literal value of the expression but that doesnt return anything either.
Test = Cstr(DateAdd(d,DateDiff(d,0,BookingDate),0))
Response.Write("<b><font color='0000ff'>" & Test & "</font></b>")
Can anyone tell me what I'm missing here?
View Replies
View Related
I'm trying to code a drop down for a date entry that gives the user the option of the current date plus the dates of the last 7 days.
<%
for i = -7 to -1
Response.write "<option>" & DateAdd(d,i,Date())
& "<option>"
next
%>
Besides this, even the following code generates an error:
Today=Date()
Response.write DateAdd(d,5,Today)
View Replies
View Related
I need to add 1 day to a specific date. The date have is stored in a variable called "DateOld". The value of the variable have this syntax: mm.dd.yyyy. The new date is the variable called "DateNew".
This is my code that dont work:
DateNew = DATEADD(d,1,DateOld)
What is wrong here? I get this error message: Invalid procedure call or argument: 'DATEADD'.
View Replies
View Related
I'm trying to add hours together in the format HH:MM + HH:MM. There doesn't seem to be a functional part of DateAdd that will accomplish this though ?
The calculation is to work out how many hours have been spent on a website so exceeding the 24:00 is fine. Is there another function that would accomplish this?
View Replies
View Related
This sort of stuff really gets me!I've been using the DateAdd function in various places to return results from the last 3 months e.g.
Code:
SELECT * FROM table WHERE publicationDate > #" & DateAdd("m",-3,now) & "#"
It's been working fine until today when I get into work and suddenly no records are showing up.If I substitute a date from 3 months ago for the function, the records reappear.
View Replies
View Related
I need to display on a web page a 7 day week split up into 30 minute blocks.
I have written the code below to do this. No doubt it is a load of rubbish (I know the bit that prints the days of the week is, but I'm not worried about that for the moment, I'm more concerned about getting the times correct).
The problem is that I cannot get it to print out midnight. The day starts at 00:30:00 and ends at 23:30:00.
Looking at the code below, can anyone suggest how I might be able to do this please?
I know I could just type in something like:
<TD>00:00:00 AM</TD> manually, but I want it to go in via a loop so I can compare it against data that will eventually be pulled from a database.
View Replies
View Related
The code generating the page is as follows:
testdate = "1/29/2003 1:00:00 PM"
while count <> 5
testdate = dateadd("n",15,testdate)
response.write testdate & "<br>"
count = count + 1
wend
What is going on there? The times should be incrementing by 15 minute intervals, not 14min and 59 seconds. I have several pages that have suddenly stopped functioning because of this strange date calculating. My web host insists there is nothing wrong with the ASP service.
View Replies
View Related
I'm trying to increment between the end of lunch and the end of the day. The code below is returning a datePart of 13 instead of 1 (for 1:00:00 PM) and 14 instead of 2:00:00 PM etc. If response.write just counter2 I get a real hour. how can I return the actual hour datePart?
lunchStart = "12:00:00 PM"
lunchEnd = "1:00:00 PM"
dayEnd = "5:00:00 PM"
counter2 = cdate(lunchEnd)
while counter2 >= cdate(lunchEnd) AND counter2 <= cdate(dayEnd)
response.write datePart("h",counter2)
counter2 = dateAdd("h",1,counter2)
wend
View Replies
View Related
Im trying to use the DateAdd and Now() functions so that I can specify some sql statements into my access db. Code:
View Replies
View Related
I am developing a simple booking system where I had a booking date. The problem is I want to make sure that the user must book 3 days in advanced for certain room.
I have tried to use DateDiff but it seems doesn't work. Actually i just 1 to make sure that the user must book 3 days in advanced from the current date. I am wondering whether there is anything goes wrong in my datediff function. Code:
View Replies
View Related
i'm new here and i'd like to ask if there's someone who knows how to compare date() function and date from database with date/time type inside select statement so i don't have to do if..then..else
View Replies
View Related
sql = "UPDATE Marknad SET" _
& " Typ ='" & Typ & "'" _
& ", Modell ='" & Modell & "'" _
& ", Arsmodell ='" & Arsmodell & "'" _
& ", Beskrivning ='" & Beskrivning & "'" _
& ", Stad ='" & Stad & "'" _
& ", Prisidé ='" & Priside & "'" _
& ", Fornamn ='" & Fornamn & "'" _
& ", Efternamn ='" & Efternamn & "'" _
& ", Telefon ='" & Telefon & "'" _
& ", Epost ='" & Epost & "'" _
& ", Datum ='" & Datum & "'" _
& " WHERE (((Marknad.Annonsnr)=" & Request.QueryString("id") & "))"
DatabaseConnection.Execute sql
---
Above does work as I want it to do BUT it inserts 1/8/2006 instead of 8/1/2006 as it should!
The best thing would be to exclude the date from updating at all, but when taking away the line:
& ", Datum ='" & Datum & "'" _
It gives an error... how do I solve this?
I forgot, you might want to see this:
Datum = date
View Replies
View Related
In my page i have two combobox. one for year and one for week numbers.Now my prob is
1.when i select a year from combo box 1, second combox box will display the number of weeks in that year.eg if i select 2005 it display me list from 1 to 53 as there are 53 weeks in 2005.
2.when i select a weeknumber from combobox 2 and press submit button it ll display start date and end date of entered week.
View Replies
View Related
I am trying to compare two dates. My problem is no matter what the value of mydate, it is still fall in the first IF statement condition (even if mydate is 10/10/2004). Any advise for this matter?
mydate = "6/6/"&year(date)
IF date() <= mydate THEN
response.write "first half of the year"
ELSE
response.write "second half of the year"
END IF
View Replies
View Related
I am trying to construct an SQL statement that can grab all of the entries out of a table, where the Date field consists of today's date. The Date field is called 'DateTime' - and it is in a General Date format (DD/MM/YYYY HH:MM:SS). I obviusly want to use an SQL statement like this:
SELECT * FROM tblExample WHERE (DateTime = Date());
However, that wont work because Date() will only return a short date (DD/MM/YYYY).
View Replies
View Related
I would like to modify this so that the first available date that can be selected is five BUSINESS days out. The script only shows Mon-Fri so if the date is Tue Jul 13, 2004, Tue Jul 20, 2004 needs to be displayed. Code:
View Replies
View Related
I am trying to compare a date in my database to the current date. MySQL statement is:
sqltemp5="select * from users where dateclosed <= '" & date & "'"
What I am trying to accomplish is exclude records where the dateclosed field is older than todays date. Such as if dateclosed = 6/30/2004 then today being 08/25/2004 that record should be excluded.
View Replies
View Related
In a connection string, I have the following:
sql3 = "SELECT DISTINCT State FROM Property Where TypeID = '" & srch_cat & "'"
In the database, is a field called expiredDate I am trying to show only records whose expiredDates are greater than todays date, but I am messing up somewhere. The values in the fields are as this: 3/7/03 (or something like that...no time is added to it)
View Replies
View Related
"SELECT id, title FROM Businesses WHERE Date_Added >= " &
Request.Form("Since_Date")
This SQL string returns all records from the table Businesses and does
not seem to be able to recognise Request.Form("Since_Date") as a valid
date. The Since_Date value is entered into a form field as
"01-Jan-2005" and appears to be treated as a date; when viewing the
SQL statement(with a response.write) it shows the date as 1/1/2005
even if it is entered into the form as 2005/1/1
I've also tried CDate(Request.Form("Since_Date")) with no luck,
although this was the treatment that worked when the SQL statement was
running in an .idc file.
Date_Added is a regular DateTime field in an Access 2000 database
Any suggestions please ?????
View Replies
View Related
I'm trying to get all records from my SQL Server Database with
"DeadlineDate" = today (not today - 24 hours).
All records has a field called "DeadlineDate", and the date is stored in
this field like this: 13.08.2005 07:00:00
I dont care about the hours (Ex: 07:00:00), just the date (ex: 13.08.2005).
This is the SQL I have made, it gets all the record with the date = today -
24 hours... but that is not what I want.
sql = "select title from tblProject where (deadlineDate BETWEEN DATEADD(d, -
1, GETDATE()) AND GETDATE())"
How can I get just the records that has the date = today's date??
View Replies
View Related