September 24, 2008 at 5:06 am
Dear All,
When you run the following command:
SELECT GETDATE() AS [CurrentDateTime]
The Result is : 2008-09-24 12:47:11.587
The question is: How can I get the following result from the above query:
20080924
September 24, 2008 at 5:10 am
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 102), '.', '')
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 24, 2008 at 5:11 am
obarahmeh (9/24/2008)
Dear All,When you run the following command:
SELECT GETDATE() AS [CurrentDateTime]
The Result is : 2008-09-24 12:47:11.587
The question is: How can I get the following result from the above query:
20080924
Where do you want to show/use formatted dates?
If it is only for display
SELECT convert(varchar(8),getdate(),112)
Failing to plan is Planning to fail
September 24, 2008 at 5:13 am
Chris Morris (9/24/2008)
SELECT REPLACE(CONVERT(VARCHAR(10), GETDATE(), 102), '.', '')
You dont need additional replace function
See my first reply ๐
Failing to plan is Planning to fail
September 24, 2008 at 5:15 am
Thank you very much...Both of you correct.
Thanks again
September 24, 2008 at 5:18 am
obarahmeh (9/24/2008)
Thank you very much...Both of you correct.Thanks again
Well. You didnt answer to my question ๐
Failing to plan is Planning to fail
September 24, 2008 at 5:22 am
Madhivanan, quite right! I don't know why the conversion I posted is being used - possibly from a previous version. It's used extensively here to generate a suffix for export filenames.
Thanks
ChrisM
For fast, accurate and documented assistance in answering your questions, please read this article.
Understanding and using APPLY, (I) and (II) Paul White
Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
September 24, 2008 at 5:25 am
well, I have a trigger that reads the latest inserted data and insert them into another table. I've wrote the trigger, then it inserted all data from the first table, where I need only the daily data inserted. and so, I've added a condition where date = today date.
and I am checking that now.
September 24, 2008 at 5:31 am
obarahmeh (9/24/2008)
well, I have a trigger that reads the latest inserted data and insert them into another table. I've wrote the trigger, then it inserted all data from the first table, where I need only the daily data inserted. and so, I've added a condition where date = today date.and I am checking that now.
If you want to find out today's data, use
wheredatecol>=dateadd(day,datediff(day,0,getdate()),0) and
datecol<dateadd(day,datediff(day,0,getdate()),1)
Failing to plan is Planning to fail
Viewing 9 posts - 1 through 8 (of 8 total)
You must be logged in to reply to this topic. Login to reply