Dynadot Aftermarket: discover domain gems worth investing in. Visit our aftermarket.

[MYSQL] STR_TO_DATE return null value

SpaceshipSpaceship
SpaceshipSpaceship
Namecheap AuctionsNamecheap Auctions
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
AIVikingsAIVikings

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

Filters for activity feeds
Your news feed, Latest activity, and the activity tab on profiles now have filter buttons: All, Posts, Quick replies, and Other. Your...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back