NameSilo

[MYSQL] STR_TO_DATE return null value

SpaceshipSpaceship
SpaceshipSpaceship
Spacemail by SpaceshipSpacemail by Spaceship
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: white label portfolios are live. Enable yours.

We're social

Escrow.com
Spaceship
Domain Recover
CryptoExchange.com

NamePros updates

New: watch any domain
You can now watch domains on NamePros. We check each one and notify you when something changes. Search for a domain and press Watch on...
AIVikings
Catchy
  • The sidebar remains visible by scrolling at a speed relative to the page’s height.
Back