December 1, 2011 at 9:21 am
Hi
Can anyone tell me what the 0 does in the following:
SELECT DATEDIFF(m, 0, '01/01/2011');
Does it indicate the start of time as far as SQL goes and if so what is it?
Thanks
December 1, 2011 at 9:25 am
Kwisatz78 (12/1/2011)
HiCan anyone tell me what the 0 does in the following:
SELECT DATEDIFF(m, 0, '01/01/2011');
Does it indicate the start of time as far as SQL goes and if so what is it?
Thanks
It indicates '1900-01-01 00:00:00'
SELECT CAST(0 AS DATETIME)
Bear in mind that this isn't the start of time as SQL sees it, e.g. try this
SELECT CAST(-1 AS DATETIME)
December 1, 2011 at 9:35 am
Ahh many thanks
December 1, 2011 at 9:44 am
You can actually change the zero date at a server-level, so test it before you count on that. Won't matter if it's being used to strip parts off of dates (like midnight calculations or 1st of month calculations), but might matter if it's being used for something else.
- Gus "GSquared", RSVP, OODA, MAP, NMVP, FAQ, SAT, SQL, DNA, RNA, UOI, IOU, AM, PM, AD, BC, BCE, USA, UN, CF, ROFL, LOL, ETC
Property of The Thread
"Nobody knows the age of the human race, but everyone agrees it's old enough to know better." - Anon
December 1, 2011 at 10:02 am
GSquared (12/1/2011)
You can actually change the zero date at a server-level, so test it before you count on that. Won't matter if it's being used to strip parts off of dates (like midnight calculations or 1st of month calculations), but might matter if it's being used for something else.
Wow, wasn't aware you could change it! Going to have to change some of the hacks I've had to do due to the lack of a calendar table, thanks 😛
Viewing 5 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply