By peshvari, on July 19th, 2011%
To format a date as MM-DDD-YY
Today:
REPLACE(right(UPPER(convert(varchar(20),getdate() ,06)), len(convert(varchar(20),getdate(),06))), ‘ ‘, ‘-’)
to get Yesterday’s date:
PRINT REPLACE(right(UPPER(convert(varchar(20),getdate()-1 ,06)), len(convert(varchar(20),getdate()-1,06))), ‘ ‘, ‘-’)
Extra date format for Microsoft SQL:
Continue reading SQL 2005 MM-DDD-YY format
By peshvari, on March 19th, 2009%
This statement will count number of records in a given month and breakdown it every 30 minutes.
select count(ID) as ID_Count, Date_30min from
( select ID, convert(datetime,convert(varchar(14),calldatetimefield,120) + case when datepart(minute,calldatetimefield) < 30 then ‘00′ else ‘30′ end) as date_30min
from tablename where calldatetimefield between ‘2009-02-01 00:00:00.000′ and ‘2009-02-28 23:59:59.997′ and ……) . . . → Read More: SQL breakdown TIME
By peshvari, on March 10th, 2009%
MS SQL to update a field to current time:
update tbl1 set col1 = convert(varchar(5),getdate() ,108)
result:
col1 . . . → Read More: SQL updating field with current timestamp