Link to home
Avatar of Member_2_4286571
Member_2_4286571

asked on

Search query only by year.

Hi guys,

I need to select highest number based on specific year.

Select max(num) from SomeTable where Date like '%2012%'

now this is not good since month 12 and day 20 in 2013 year will also respond to this query.

my date format is ddMMyyyy.

Any suggestions?
Avatar of Steve Wales
Steve Wales
Flag of United States of America image

How about this:

If the column ends in yyyy:

Select max(num) from SomeTable where Date like '%2012'
Avatar of Member_2_4286571
Member_2_4286571

ASKER

Unfortunately in database date looks like this 2012-10-29 00:00:00.000.

I am using ddMMyyyy in VB.net, but in database is displayed differently.
ASKER CERTIFIED SOLUTION
Avatar of tim_cs
tim_cs
Flag of United States of America image

Blurred text
THIS SOLUTION IS 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
That's it, thank you.