Wrox Programmer Forums
|
ASP.NET 2.0 Basics If you are new to ASP or ASP.NET programming with version 2.0, this is the forum to begin asking questions. Please also see the Visual Web Developer 2005 forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the ASP.NET 2.0 Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old October 28th, 2007, 05:32 PM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default date format yyyymmdd


hi!
I want to convert a date data collected from a user in dd.mm.yy format to yyyymmdd format and svae it in a database.

How can I convert date from dd.mm.yy format to yyyymmdd format?
any suggestion will be appreciated.

thank you in advance

 
Old October 28th, 2007, 08:22 PM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

hi there.. the format function is not enough for you??

datetime.tostring("yyymmdd")??

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old October 29th, 2007, 02:58 AM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

hi !
Thank you for your reply! I have tried what you have suggested me but it did not work. it gives me wrong number for the month "mm".

I have tested the following code . The code displays wrong output.


<script runat="server">

    Sub Page_Load()
            
             Response.write(DateTime.Now.ToString())
             Response.write("**************")
            
             Response.write(DateTime.Now.ToString("yyyymmdd") )
             Response.write("=========")
            
             Dim dt as Date=Format(Now(),"dd/MM/yyyy")
             response.write(dt)
    end sub

</script>

output:

29.10.07 08:54:25********20075429=========29.10.07 00:00:00

I am getting wrong number - 54 for mm, which is not true


can someone help me.
 
Old October 29th, 2007, 06:59 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

yep.. you are rigth.. you have to use MM... mm is for minutes...just use yyyyMMdd

HTH

Gonzalo

================================================== =========
Read this if you want to know how to get a correct reply for your question:
http://www.catb.org/~esr/faqs/smart-questions.html
^^Took that from dparsons signature and he Took that from planoie's profile
================================================== =========
My programs achieved a new certification (can you say the same?):
WORKS ON MY MACHINE
http://www.codinghorror.com/blog/archives/000818.html
================================================== =========
I know that CVS was evil, and now i got the proof:
http://worsethanfailure.com/Articles...-Hate-You.aspx
================================================== =========
 
Old October 29th, 2007, 07:52 AM
planoie's Avatar
Friend of Wrox
 
Join Date: Aug 2003
Posts: 5,407
Thanks: 0
Thanked 16 Times in 16 Posts
Default

belete -

Why are you storing a date value as a string instead of a datetime? If you store it as a datetime time it will be MUCH easier to format it later without having to always convert it from a string into a real date value. It's probably also more efficient because it will store the value as a numeric value instead of just a string of characters.

-Peter
 
Old October 29th, 2007, 08:24 AM
Authorized User
 
Join Date: Jun 2004
Posts: 55
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you guys it is now working!

Planoie:
It is better to save it as datetime as you have said. I will later reterive it back by using GridView from the database. It will be much easier.

belete






Similar Threads
Thread Thread Starter Forum Replies Last Post
date format differs, need to force format somehow patricolsson ASP.NET 2.0 Basics 1 December 3rd, 2009 12:53 AM
Convert British format date to American format? fyr PHP How-To 0 December 19th, 2007 03:17 PM
Validating date(yyyymmdd) with RegularExpressionVa belete ASP.NET 2.0 Basics 2 October 23rd, 2007 12:30 PM
How to give Date format while entering date Subuana Beginning VB 6 4 March 17th, 2006 07:25 AM
date format differs, need to force format somehow patricolsson HTML Code Clinic 2 January 12th, 2006 05:55 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.