NameSilo

[MYSQL] STR_TO_DATE return null value

Namecheap AuctionsNamecheap Auctions
SpaceshipSpaceship
NamecheapNamecheap
Watch

DNK.it

Domain Name KeyVIP Member
Impact
79
[SOLVED] [MYSQL] STR_TO_DATE return null value

Hi all,
I need to select from my database only the yesterday value. The problem is that the value data is set to VARCHAR so I've used STR_TO_DATE to convert it:

Code:
SELECT data_string_field FROM table
WHERE STR_TO_DATE(data_string_field, "%m/%d/%Y") = DATE_ADD( CURDATE(), INTERVAL -1 DAY );

but this string return null value instead of yesterday values ;(

any help will be appreciated
 
Last edited:
0
Close
The views expressed on this page by users and staff are their own, not those of NamePros.
GoDaddyGoDaddy
Make sure that the string values are in the expected format, and that there are no invalid dates like 31-Feb.
PS: it would be a good idea to convert that field to date type to avoid manipulations.
 
1
Close
Kath said:
Make sure that the string values are in the expected format, and that there are no invalid dates like 31-Feb.
PS: it would be a good idea to convert that field to date type to avoid manipulations.

Thanks for the reply Kath, rep+.
I've solved the issue :)
The date field is printed as 04/23/2008 , but is stored in db as 2008-04-23, so I've only changed "%m/%d/%Y" in "%Y-%m-%d" :p

Thanks,
Antonio
 
0
Close
DomainEasy: flexible LTO options. Close more domain deals with financing.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Switch between accounts
You can now stay logged in to more than one NamePros account in the same browser. Click your avatar, then "Accounts in this browser", to...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back