About
Pricing
Community
Teams
Start Free Trial
Log in
ghettocounselor
asked on
4/10/2015
SQL - CONVERT or whatever is used to take txt field CUSTOM_FIELD and extract date and then use in WHERE statement
Table : PHM_ENHANCED_CHGS
Field : CUSTOM_FIELD
Data type : text
Example : 201503302304
Field is a date time stamp.
I need to be able to do whatever is needed to the field data and then do a WHERE date between here and here.
Microsoft SQL Server
SQL
3
1
Last Comment
ghettocounselor
8/22/2022 - Mon
dsacker
4/10/2015
Without knowing your table name or fields names, this may get you going:
SELECT *
FROM YourTable
WHERE CONVERT(datetime, MyStringField) BETWEEN '2015-01-01' AND '2015-03-31 23:59:59.997'
If your fields do not have the time with the date, you can try this:
SELECT *
FROM YourTable
WHERE CONVERT(datetime, MyStringField) BETWEEN '2015-01-01' AND '2015-03-31'
ASKER CERTIFIED SOLUTION
Scott Pletcher
4/10/2015
THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
ghettocounselor
4/10/2015
ASKER
Duh! sheesh, funny how sometimes you look at something and don't see the simplicity available. Thanks!
All of life is about relationships, and EE has made a viirtual community a real community. It lifts everyone's boat
William Peck
SELECT *
FROM YourTable
WHERE CONVERT(datetime, MyStringField) BETWEEN '2015-01-01' AND '2015-03-31 23:59:59.997'
If your fields do not have the time with the date, you can try this:
SELECT *
FROM YourTable
WHERE CONVERT(datetime, MyStringField) BETWEEN '2015-01-01' AND '2015-03-31'