Click here to Skip to main content
14,420,468 members
Rate this:
Please Sign up or sign in to vote.
See more:
hi all,

my PC date settings is dd/mm/yyyy and my application is working fine regarding searching by date or inserting or updating.

but when i uploaded my website to my host which its date format is mm/dd/yyyy.

all my works destroyed because for example i can't insert 19/08/2015 which will cause error or even in querystring

for example "mypage.aspx?Date=19/08/2015" will cause error too. how can i make the inserting(19/08/2015) and selecting by date working ??

i want to insert 19/08/2015 to my table which causes error in formview

Maciej Los 19-Aug-15 16:01pm
The date setting on local machine is not important! The way you save data into database is very important! Please, improve your question.

1 solution

Rate this:
Please Sign up or sign in to vote.

Solution 1

Always use explicit, non-ambiguous formats. So rather than adding your Date param like;

& "Date=" & dt.ToString()

use a specific format

& "Date=" & dt.ToString("yyyy-MM-dd")

When you read the param from the querystring convert it from that format

DateTime dt;

DateTime.TryParseExact(Request.QueryString["Date"], "yyyy-MM-dd", System.Globalization.CultureInfo.InvariantCulture, System.Globalization.DateTimeStyles.None, out dt);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100