SQL Syntax


Author
Message
Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K
Trent,

Thanks for the follow-up.  I hadn't heard anything and figured it had got lost in the mix.

-Larry

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
I will definitely look at this and if there is a bug I will let you know and we will include a fix in the next update.  I need to dig a little more to see why you might be having this issue.
Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

Any more suggestions on this? Should I assume that the browse dialog functions as designed and can’t find records with a date equal to just the date portion of a datetime field or is it something that will be fixed?

Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

Trent,

 

BeginsWith is not an option for a field defined as datetime, it’s only available for text fields.  For datetime fields the options are =, >, <, >= or <=.

 

Flavelle,

 

Thanks for the suggestion.

 

-Larry

 

 

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
On the BrowseDialog, set it to searching with a BeginsWith and see if that resolves your problem.  This should exclude the time.
Flavelle Ballem
Flavelle Ballem
StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)StrataFrame User (150 reputation)
Group: Forum Members
Posts: 56, Visits: 126
Another approach to stripping the time from a date is to do a double cast as shown below:

cast(cast(@date as int) as datetime)

This was suggested to me on an MSDN forum and works very well.

Regards,

Flavelle

Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

Using a SF maint form containing a SF textbox (Name) and SF DateTimePicker (DateTime) with StripTimeFromValue = True I added some records to a table.  All of the dates have a time of 12:00:00 AM.

 

 

If I use a BrowseDialog and try to select a date equal to, it fails to find the record. I don’t know if the DateTimePicker on the browse dialog is configured to StripTimeFromValue and that may be the issue. However in most cases my applications would have a meaningful time component to the DateTime field and I’d want to be able to search on just the date portion.

 

-Larry

 

Trent Taylor
Trent Taylor
StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)StrataFrame Developer (14K reputation)
Group: StrataFrame Developers
Posts: 6.6K, Visits: 7K
If you are using the StrataFrame DateTime control, there is a property that is called StripTimeFromDate (or something similar to that Smile )...anyway, this will remove the time from the date and will always be consistent when searching or selecting.  It is basically midnight and would look something like this: 12/01/2006 00:00:00 .  If you have a time in teh date column, the yes, this would be a problem when searching.  In this case you would have to take the time into account.
Larry Caylor
Larry Caylor
StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)StrataFrame VIP (1.8K reputation)
Group: Awaiting Activation
Posts: 592, Visits: 3.7K

This problem is similar to the issue I listed under enhancements to the BrowseDialog.  To select records by date, ignoring the time component on a SQL DateTime field you can do the following

 

Public Sub FillByDate(ByVal ldDate As Date)

   Dim loCommand As New SqlCommand

   loCommand.CommandText = "SELECT * FROM Library” _

                                              "WHERE CONVERT(Char(10),Media_date,101) = @SearchDate"

   loCommand.Parameters.Add("@SearchDate", SqlDbType.Char)

            loCommand.Parameters("@SearchDate").Value = string.Format("{0:MM/dd/yyyy}",ldDate)

   Me.FillDataTable(loCommand)

End Sub

 

-Larry

StrataFrame Team
S
StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)StrataFrame Developer (6.5K reputation)
Group: StrataFrame Developers
Posts: 3K, Visits: 2.5K
Nope, all dates in SQL Server have the time attached to them.

If you're setting the value in your default values, you can do this instead:

me.myfield = DateTime.Now.Date

Accessing the .Date property of a DateTime will return the date with the time truncated (alternatively, you could use the .TimeOfDay property to access just the time portion).

However, if you're setting the property in other ways, you can customize the property in the BOMapper to set the data within the business object to the .Date of the value passed.

GO

Merge Selected

Merge into selected topic...



Merge into merge target...



Merge into a specific topic ID...




Similar Topics

Reading This Topic

Login

Explore
Messages
Mentions
Search