Results 1 to 5 of 5

Thread: format date in mysql not working

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2009
    Posts
    211

    format date in mysql not working

    hi!

    I'm trying to execute this line but its not working.

    Code:
    txtdate=format(now,"yyyy/mm/dd")
    the result should be 2010/05/19 instead its 05/19/2010. I'm using vb6 and mysql.I'm trying to compare the date in my database and the current date.and since the date format of mysql is yyyy/mm/dd i need to format the current date for them to meet.is there something missing in my code?


    Thanks!

  2. #2
    Freelancer akhileshbc's Avatar
    Join Date
    Jun 2008
    Location
    Trivandrum, Kerala, India
    Posts
    7,652

    Re: format date in mysql not working

    I don't see any problem with the code:
    Code:
    Private Sub Command1_Click()
        Me.Caption = Format(Now, "yyyy/mm/dd")  '~~~ Gives 2010/05/19
    End Sub
    Did you tried using Date instead of Now ?
    ....

    If my post was helpful to you, then express your gratitude using Rate this Post.
    And if your problem is SOLVED, then please Mark the Thread as RESOLVED (see it in action - video)
    My system: AMD FX 6100, Gigabyte Motherboard, 8 GB Crossair Vengance, Cooler Master 450W Thunder PSU, 1.4 TB HDD, 18.5" TFT(Wide), Antec V1 Cabinet

    Social Group: VBForums - Developers from India


    Skills: PHP, MySQL, jQuery, VB.Net, Photoshop, CodeIgniter, Bootstrap,...

  3. #3
    Super Moderator si_the_geek's Avatar
    Join Date
    Jul 2002
    Location
    Bristol, UK
    Posts
    41,974

    Re: format date in mysql not working

    Quote Originally Posted by enigmagirl122 View Post
    is there something missing in my code?
    Yes, at least in terms of what you posted.

    You have not given any indication of what txtdate is, or shown us anything at all to do with databases.

  4. #4
    PowerPoster Spoo's Avatar
    Join Date
    Nov 2008
    Location
    Right Coast
    Posts
    2,656

    Re: format date in mysql not working

    Quote Originally Posted by enigmagirl122 View Post
    I'm trying to execute this line but its not working.

    Code:
    txtdate=format(now,"yyyy/mm/dd")
    the result should be 2010/05/19 instead its 05/19/2010.
    Enigma

    Hmmm.. I just tried that, and I get "2010/05/19"
    Unfortunately, I don't understand why you would not get the same result.

    EDIT:

    In case the image isn't self-evident, I put a breakpoint in my
    sub, and hovered the mouse over "txtdate" (the mouse pointer
    does not appear in the image) ...

    ... hence the tooltip is returning the value of "txtdate"

    Spoo

    .
    Attached Images Attached Images  
    Last edited by Spoo; May 19th, 2010 at 08:22 AM.

  5. #5
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,687

    Re: format date in mysql not working

    is there something missing in my code?
    Yes... the REAL code... not some sample contrived code that works... your example has nothing to do with mySQL... so clearly there are other factors involved. So maybe if you showed us the real code that you are using you'll get more useful answers besides "It works for me."

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width