473,566 Members | 2,784 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 1541
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
5969
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
2600
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' Type mismatch.
0
1945
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 yyyy part come from? It looks as if DateFormat does not look in the overriden format on the Date tab and just assumes that English(US) is fixed to...
2
1538
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. However, my Web app is not accepting dates of format dd/MM/yyyy only MM/dd/yyyy
4
4224
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 separator could be slash or a dash ("-"). The file is in a proprietary format, and bcp is not an option. So, I decided to load the file using a...
3
1346
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 this 00 denotes which month. I want to store 01-12 (not 00-12 ) months. How can i do this ,i already change the date format with the above query but...
1
2949
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 who can help me this problems?
0
1439
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 System.Globalization.DateTimeFormatInfo DateFormat.ShortDatePattern = "mm/dd/yyyy" Please help me
1
3208
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 fields that are passed are strings representing dates. E.G. 20080324 ( which I read as 2008/03/24) Sometimes they are there sometimes they are not....
3
2770
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" Java reports locale as en_US, windows regional settings are set to Bosnian (Bosnia and Herzegovina), language to use for non-unicode programs is English...
0
7666
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
0
7888
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
1
7644
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
0
7951
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5484
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5213
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3643
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3626
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1201
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.