Date?

If you need help with a project or need to know how to do something specific in VB.NET then please ask your questions in here.
Forum rules
Please LOCK your topics once you have found the solution to your question so we know you no longer require help with your query.
11 posts Page 1 of 2
Contributors
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Date?
Dummy1912
Hello,

we having some troubles with our date support
in our DB we have it like
Code: Select all
yyyy-mm-dd hh:mm
one 1 pc it works nice
but when we use our other pc's where the date system is diffrent
we get a error that he can't load the date.

this pc has the date system: yyyy-mm-dd
other pc has: mm/dd/yyyy
other pc has: mmm d, yyyy

as you can see it always change
is there a whay that our program just load the date from our DB function
to any pc system date?
Code: Select all
'## Start
                        Dim sDate1 = 2016-08-16
                        Dim fDate1 = Regex.Replace(sDate1, "^(\w+?)(\d{1,2})(\d{4})$", "$1/$2/$3", RegexOptions.Multiline)
                        'Formats date
                        Dim dt1 = DateTime.ParseExact(fDate1, "MMM/d/yyyy", New CultureInfo("en-US"))

                        '## End
                        Dim sDate = 2016-08-20
                        Dim fDate = Regex.Replace(sDate, "^(\w+?)(\d{1,2})(\d{4})$", "$1/$2/$3", RegexOptions.Multiline)
                        'Formats date
                        Dim dt = DateTime.ParseExact(fDate, "MMM/d/yyyy", New CultureInfo("en-US"))

Thanks

Dummy
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: Date?
CodenStuff
How are you storing/saving the date to the database? can you show a little code please
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Date?
Dummy1912
Hello Cns,

well it just been stored as a normal string

Image
Code: Select all
Database.modifyDatabase("INSERT INTO scheduler VALUES (null," & Util.quote(SetEmployeeID.ToString) & ", " & Util.quote(mdtpmultiplyStart.Value.ToString("MMMMdyyyy")) & ", " & Util.quote(mdtpmultiplyEnd.Value.ToString("MMMMdyyyy")) & ", " & Util.quote(SetShiftstart) & ", " & Util.quote(SetShiftend) & ", " & Util.quote(GetEventID) & ", " & Util.quote("") & ", " & Util.quote(txtremarks.Text) & ", " & Util.quote(monthid) & ", " & Util.quote(yearid) & ");")
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: Date?
CodenStuff
Never seen that date format before. It's usually mm-dd-yyyy or dd-mm-yyyy

Would it be easier to save to DB in datetime/timestamp format?
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Date?
Dummy1912
Not sure....
if you can give me a great example how it should look and works
and add it into the db datetime/timestamp format
then i can try it out and hope it will :)

thanks
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: Date?
CodenStuff
I'm not sure lol. I guess the database field should be a 'timestamp' format not text :duh;

But if you're storing the date in a text field that looks something like: "2016-08-22 11:32" when it's entered in to the database then can't you just output that from the database as it as...as a string and display it.

Or are you already doing that and you just want to change "2016-08-22 11:32" to look like "2016/08/22" when it's displayed?

I'm a little lost lol
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Date?
Dummy1912
I will try to find you then :D

well it already has been stored as a datetime in our db but as TEXT
but it seems when you save the datetime in the db and use the db on a other computer with the system datetime in a other display to show
there will be some troubles to load from the db?
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
CodenStuff
Site Admin
Site Admin
Posts: 4389
Joined: Tue Aug 04, 2009 1:47 am

Re: Date?
CodenStuff
I'm unsure how to solve your problem to be fair :duh;

I'm still a little lost with it all lol

But I did make a small app to test things out with different cultures etc, you can download and try it if you want maybe it will help.

However, I found that if you put the date output as "yyyy-mm-dd hh:mm" it came out the same regardless of culture used :\

I don't know.
dummydatetime.zip
You do not have the required permissions to view the files attached to this post.
Welcome to CodenStuff.com Learn Code, Love Code. Thank you for being a member of the community.
User avatar
Dummy1912
VIP - Donator
VIP - Donator
Posts: 1969
Joined: Sat Aug 21, 2010 2:17 pm

Re: Date?
Dummy1912
Thank you
i will check it out and come back to you ;)
visit us on:


http://www.softpedia.com/get/System/Lau ... -Run.shtml
Check it out ! http://www.softpedia.com/publisher/I-A- ... 90017.html
Check it out ! http://www.softpedia.com/get/Desktop-En ... lock.shtml
User avatar
Codex
Coding God
Coding God
Posts: 2028
Joined: Wed Mar 31, 2010 5:50 pm

Re: Date?
Codex
It appears in the first post, you wrote that you are using the format "MMM/d/yyyy", which is 3 M's
You are tho using another format in the second post, where you are inserting into the database "MMMMdyyyy", which is 4 M's.

Now I do not know of the formatting that you are using, but it clearly doesn't match the 2 examples you provided. Try fixing that first, and then see if it works
We shall let the revolution begin.. the revolution for freedom, freedom against censorship. We shall fight in the fields and in the streets, we shall fight in the hills; we shall never surrender
11 posts Page 1 of 2
Return to “Coding Help & Support”