SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 formating date results
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

joblenis
Starting Member

Canada
29 Posts

Posted - 06/05/2007 :  11:43:32  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 06/05/2007 :  12:00:26  Show Profile  Reply with Quote
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

Canada
29 Posts

Posted - 06/05/2007 :  12:43:25  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

2161 Posts

Posted - 06/05/2007 :  13:00:37  Show Profile  Reply with Quote
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

India
22772 Posts

Posted - 06/06/2007 :  09:56:25  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
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

Edited by - madhivanan on 06/06/2007 09:58:20
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000