Solved

'yyyymmdd' - need help with file formatting

Posted on 1999-01-25
1
1,234 Views
Last Modified: 2008-03-10
Hello.
here is the problem: I need to create a text file in Sybase where one of the values has the format char(8) 'yyyymmdd'. There is no such format in Sybase's convert function.  So, I use convert(char(4),datepart(yy,GetDate())) + same for month and + same for day.The problem is when month is 1, I get 1999125 which means 1999 Jan 25, and even if I add a space to make it up to 8 characters it does not resolve the problem, because it is not clear if 1999125 1999 Dec 5 or 1999 Jan 25.
Does anyone know how to select 19990125 meaning 1999 Jan 5th?
0
Comment
Question by:alla012599
1 Comment
 
LVL 7

Accepted Solution

by:
spiridonov earned 30 total points
ID: 1098593
Use Case statement and datalength function:
(CASE DATALENGTH(CONVERT(VARCHAR(2),datepart(yy,getdate()))) WHEN 1 then CONVERT(VARCHAR(2),datepart(yy,getdate())) ELSE '0'+CONVERT(VARCHAR(2),datepart(yy,getdate())) END)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article lists the top 5 free OST to PST Converter Tools. These tools save a lot of time for users when they want to convert OST to PST after their exchange server is no longer available or some other critical issue with exchange server or impor…
Some code to ensure data integrity when using macros within Excel. Also included code that helps secure your data within an Excel workbook.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…
I designed this idea while studying technology in the classroom.  This is a semester long project.  Students are asked to take photographs on a specific topic which they find meaningful, it can be a place or situation such as travel or homelessness.…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now