Solved

Date Formats

Posted on 2004-08-13
10
218 Views
Last Modified: 2012-05-05
I guys,

I'm developing an application that retrieves info from a Web Service, they scrick their date formats as MM/dd/yyyy , i'm using uk format dd/MM/yyyy and when i convert the date to MM/dd/yyyy with datetime.parsexact(d,"MM/dd/yyyy",nothing) it keeps sending me dd/MM/yyyy even if i change the d variable manualy to MM/dd/yyyy.

i've tried changing LCID but unfortunatelly it retrives for example the day 8 as 8 and i need it as 08, i'm a bit stuck in here can anyone help,

ah by the way i've tried as weel dim nDate as date = "12/08/2004" but it crashes, i've tried changind LCID before but the date becomes "12/8/2004" and thats not what i want,

can anyone help?

Cheers
0
Comment
Question by:JunkMan
  • 5
  • 5
10 Comments
 
LVL 11

Expert Comment

by:saleek
ID: 11791700
Hi, just to get the obvious out of the way....

Is your client machine's regional setting on UK?

You are receiving the date from the webservice as mm/dd/yyyy, but you want to display it on your application as dd/mm/yyyy?

Is it a windows application you are working with or a web application?


regards,

KS
0
 
LVL 3

Author Comment

by:JunkMan
ID: 11791752
saleek : look at were the post is done (ASP.net) can only be a web application,
no i'm trying the oposite i have a calendar returning in dd/mm/yyyy and i want to convert to mm/dd/yyyy the problem is that it is triming the leading zeros, thing that it shouldn't do but it is..

i.e:
session.lcid = 1033
dim origDate as string = "20/08/2004"
dim nDate as date = datetime.parseexact(origDate,"MM/dd/yyyy", system.globalization.cultureinfo.CurrentCulture)
response.write nDate.tostring

it is returning 8/20/2004 but i want 08/20/2004 i can only assume that the lcid is overriding the parseexact function because i have MM and it should return the leading zero..


thanks mate...
0
 
LVL 11

Expert Comment

by:saleek
ID: 11791786
Junkman,

People do mistakenly post web questions in application section and vice versa, that is why I asked.

Have you tried leaving out the parseexact and just using, datetime.ToString("MM/dd/yyyy")?


regards,

KS
0
 
LVL 3

Author Comment

by:JunkMan
ID: 11791837
i've tried that allready, the thing is that i need to send the variable as date and when it is being set to the variable it is triming the leading zeros. that is my problem.

do you know if there is another LCID for US that will maintain the leading zeros, i think that my problem could be that.
0
 
LVL 11

Expert Comment

by:saleek
ID: 11792166
Junkman, try this....

Dim origDate As String = "20/08/2004"
Dim nDate
nDate = Right(Left(origDate, 6), 3) & Left(origDate, 3) & Right(origDate, 4)

nDate = CType(nDate, Date)
Response.Write = Format(nDate, "MM/dd/yyyy")

Should work.

regards,

KS
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 3

Author Comment

by:JunkMan
ID: 11792439
No sorry,

well it works when doing format but format returns a string and i need it as a DATE to send the request
0
 
LVL 3

Author Comment

by:JunkMan
ID: 11792578
going by other approach is it possible to change directly the month/day in the variable type date?
0
 
LVL 11

Accepted Solution

by:
saleek earned 50 total points
ID: 11808003
I dont think so, I'll look it up...
0
 
LVL 3

Author Comment

by:JunkMan
ID: 11808031
don't bother mate, i manage to talk with the developers of the web service and they changed the type from date to string, witch will solve the problem, i'll give u the points anyway...

thanks for your help..
0
 
LVL 11

Expert Comment

by:saleek
ID: 11808048
Okay, all the best.
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
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…

757 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

19 Experts available now in Live!

Get 1:1 Help Now