October 31, 2006 at 7:07 am
Can you help me?
I'm trying to write some script to retreive a date value and then subtract 1 day from this and store the new value in a table. For example, 31/10/2006 -1 = 30/10/2006.
I know how to save the value once it is calculated, but don't know which calculation to use the acheive what I want.
Any help is greatfully received.
October 31, 2006 at 7:24 am
DATEADD(day, -1, '31/10/2006')
Far away is close at hand in the images of elsewhere.
Anon.
October 31, 2006 at 10:24 am
select Cast('31/Oct/2006' as datetime) -1 would work too.
November 1, 2006 at 8:15 am
But you also need to look up the ISO-8601 format for temproal data so you will not use a local dialect |
Yes, I forgot to mention the format of the date for conversion
Standard SQL uses only "yyyy-mm-dd" |
The only unambiguous format is yyyymmdd whereas nnnn-nn-nn (even if deemed to be yyyy-mm-dd) can be interpreted as yyyy-mm-dd or yyyy-dd-mm depending on the language settings of the login. SQL Server's default is the American format of yyyy-dd-mm.
Far away is close at hand in the images of elsewhere.
Anon.
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply