-
Convert GETDATE to yesterday 1st/last second
In search of SQL to obtain "yesterday's" begin/end times for a batch process:
GETDATE() needs to be converted to Yesterdays FIRST and LAST second:
------- --------------------------------
2001-06-25 14:23:56.054 ---> 2001-06-24 00:00:00.001 (1st sec. of yesterday)
2001-06-25 14:23:56.054 ---> 2001-06-24 23:59:59.999 (last sec. of yesterday)
Will CAST and/or CONVERT fucntions assist? The follwoing SQL returns GETDATE()-1 (yesterday along w/ a time) I need the time converted to 1st and last second...
declare @date_time_accessed datetime,
@DateAccessed varchar(80),
@TimeAccessed varchar(80)
select convert(varchar(10),getdate()-1,120) as dateaccessed,
convert(varchar(8),getdate()-1,114) as timeaccessed
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
|