473,500 Members | 1,967 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

DateFormat

8 New Member
I want to convert a date(which is in the DDMMYYYY format) into the MMDDYYYY format in sql query.below is my query but its not working??
Do anyone have any idea???

declare @s char(10)
set @s = '21/04/2008'
select convert(char(10),@s,101)
Apr 21 '08 #1
2 1536
deepuv04
227 Recognized Expert New Member
I want to convert a date(which is in the DDMMYYYY format) into the MMDDYYYY format in sql query.below is my query but its not working??
Do anyone have any idea???

declare @s char(10)
set @s = '21/04/2008'
select convert(char(10),@s,101)
Hi,
Try declaring @s as datetime and set the value as '2008-04-21'

then your query will execute currectly

Expand|Select|Wrap|Line Numbers
  1. declare @s DATETIME 
  2. --set @s = '21/04/2008'
  3. set @s = '2008-04-21'
  4. select convert(char(10),@s,101)
  5.  
  6.  
Apr 21 '08 #2
ck9663
2,878 Recognized Expert Specialist
I want to convert a date(which is in the DDMMYYYY format) into the MMDDYYYY format in sql query.below is my query but its not working??
Do anyone have any idea???

declare @s char(10)
set @s = '21/04/2008'
select convert(char(10),@s,101)

Try:

Expand|Select|Wrap|Line Numbers
  1. declare @s varchar(10)
  2.  
  3. set @s = '21/04/2008'
  4.  
  5. select convert(varchar(20), convert(datetime, @s, 103),101)
-- CK
Apr 21 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
5959
by: RP | last post by:
I need to format a date as mm/dd/yy. I don't see the Format function listed in my book, and the DatePart or FormatDateTime functions don't seem to allow for a 2 digit year? Thanks Rich
3
2598
by: Christopher Brandsdal | last post by:
I'm turning green on this!! What I need to do is insert a date from a textfield by using rsFakt("DomeneDato") = Request.Form("DatoDomene") I just get this error: Provider error '80020005' ...
0
1940
by: Phil | last post by:
My regional setting (on Win2000) is: (General Tab)Locale = English (US) (Date Tab), short date = MM/dd/yy When I ask .Net DateFormat.ShortDatePattern, I get MM/dd/yyyy Now, where does the...
2
1530
by: Grant Merwitz | last post by:
Hi I have installed my web app on a Windows 2003 server. The Regional and Language was originally set to American. Now we have changed it to UK, and are trying to get the DateFormat right. ...
4
4218
by: newtophp2000 | last post by:
Hello, I receive a file containing some character fields along with a date. The date values in the file are formatted as "dd/mm/yy", that is 2-digit day, 2-digit month, and 2-digit year. The...
3
1334
by: Geethu03 | last post by:
Hello In my table Date field contains the datatype Date.but i want to change the DateFormat as i requried,for this i used date_format(date,'%d-%m-%Y') The %m starts with the (00-12) In...
1
2944
by: afernandeziii | last post by:
Hi everyone, Please help! what's the correct syntax using DateFormat in SQL Server 2005. Example. 05/04/07 00:00:00 i need this date show like this 05/04/07 i this regard the time. Anyone...
0
1428
by: pankajol82 | last post by:
Hi all I am using following code to change regional setting at run time its not giving any error but at the same time the format of date is not changing. Dim DateFormat As New...
1
3201
zigman68
by: zigman68 | last post by:
I have a problem with the DateFormat() Function that is driving me nuts! I am downloading a csv and then parsing through it, then inserting into a SQL 2005 DB. Here is the problem. ... A number of...
3
2762
dzenanz
by: dzenanz | last post by:
String input="4/3/08 9:57 AM"; DateFormat df = DateFormat.getDateInstance(DateFormat.SHORT); StartDate = df.parse(input); out.println(StartDate.toLocaleString());//"Apr 3, 2008 12:00:00 AM" ...
0
7182
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7232
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5490
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4611
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3110
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3106
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1430
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
672
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
316
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.