Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Current date as a colunm

Author  Topic 

abuhassan

105 Posts

Posted - 2006-06-15 : 09:40:37
hi

i wanted to crete an extra colunm when i retrive a set of rows...
the date colunm must show the current date eg 15/06/2006

currently im writing it as follows

select cost, '15/06/2006' as CDate
from prices

as you can see this is static date i need the date to be current whenever the query is done.

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-06-15 : 09:46:10
Why do you want to do this?
Can you give us more details?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-15 : 10:42:58
[code]select cost, '15/06/2006' getdate() as CDate
from prices[/code]

Perform the formating of CDate to the format you want in your front end application


KH

Go to Top of Page

abuhassan

105 Posts

Posted - 2006-06-15 : 10:49:41
The reason is for auditing the changes i cannot use a time stamp or any thing else because that is the format required for the date.

basically when the data is collected and exported from the view it should provide the date of the data export.

since the other applicaton requires the data in that format and for auditing it is used to check the date..
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-06-15 : 10:54:50
quote:
Originally posted by abuhassan

The reason is for auditing the changes i cannot use a time stamp or any thing else because that is the format required for the date.

basically when the data is collected and exported from the view it should provide the date of the data export.

since the other applicaton requires the data in that format and for auditing it is used to check the date..


Then use convert to format it
select cost, convert(varchar(10), getdate(), 103) as CDate
from prices



KH

Go to Top of Page
   

- Advertisement -