Link to home
Start Free TrialLog in
Avatar of jych
jych

asked on

First day of current month in Sybase

Hi,

I have a table is Sybase with a date field.   I want to write a SQL query where I select all records where this Date Field is >= first day of the current month, so in this case, 01-NOV-2005.

Any ideas how I can accomplish this in SQL in Sybase.   My date field has a time stamp as well.

Thanks.
Avatar of RahamanM
RahamanM

Hi

try this


declare @today datetime
select @today=getdate()
select  convert(char(8), dateadd(dd, 1-datepart(day,@today), @today), 112)
This more customized for your need

declare @today datetime
select @today=getdate()
select  convert(datetime, convert(char(8), dateadd(dd, 1-datepart(day,@today), @today), 112))
Avatar of Anthony Perkins
This is how you can do that using MS SQL Server, so I assume something similar in Sybase:

Select YourDate - Day(YourDate) + 1
From   YourTableName
ASKER CERTIFIED SOLUTION
Avatar of Renante Entera
Renante Entera
Flag of Philippines image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial