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
 formating date results

Author  Topic 

joblenis
Starting Member

29 Posts

Posted - 2007-06-05 : 11:43:32
I tried looking for assistance but I cant get my formatting to work. I was pretty sure yyyy=2007 and yy=07 but its not working right.

What I am doing is using Business Intelligence to read the previous days IIS logs. The logs are labeled as ex070602.log (exyymmdd.log) The code I use to get the previous day is dateadd("d",-1,getdate())

now I want to format the yy/mm/dd but I am getting single digits for the month and day and 4 digits for the year. Can someone tell me the expression I would need to use for this. Thank you kindly guys.

Some things I tried and results I got:


datepart("yy",dateadd("dd",-1,getdate())) = 2007
year(dateadd("dd",-1,getdate())) = 2007

day(dateadd("dd",-1,getdate())) = 4
month(dateadd("dd",-1,getdate())) = 6


Thanks. I appreciate the assistance.

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-06-05 : 12:00:26
try this

select convert(char(8),getdate(),11)


[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

joblenis
Starting Member

29 Posts

Posted - 2007-06-05 : 12:43:25
that works in sql but wont work in my business intelligence expression builder. It does not like the char function. Any other ideas?
Go to Top of Page

DonAtWork
Master Smack Fu Yak Hacker

2167 Posts

Posted - 2007-06-05 : 13:00:37
Hmm. Try a google search for "Business Intelligence" i suppose. This is a Microsoft SQL Server forum.

[Signature]For fast help, follow this link:
http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspx
Learn SQL
http://www.sql-tutorial.net/
http://www.firstsql.com/tutor.htm
http://www.w3schools.com/sql/default.asp
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2007-06-06 : 09:56:25
Try

right(datepart("yy",dateadd("dd",-1,getdate())),2)+"/"+month(dateadd("dd",-1,getdate()))+"/"+day(dateadd("dd",-1,getdate()))

or search at
http://support.businessobjects.com/

Madhivanan

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

- Advertisement -