• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 406
  • Last Modified:

Time validation (IsTime)

Hi, All!
The problem is I'm trying to move my data from Excel spreadsheet to  MS SQL DB.
It's very important to keep data clean, so I need validate some columns, one of them time
Let say time is 10:59a
IsDate("10:59a") = true
But it's wrong, SQL Server won't accept it.
Any ideas how to validate time like that.
1 Solution
You could wirte an 'IsSQLServerDate' function and use tha instead.
Here's one it will need some work but you can get the idea of how to write one.

Public Function IsSQLServerDate(ByVal vIn)

    IsSQLServerDate = False
    If IsDate(vIn) Then
        IsSQLServerDate = True
        If Right(vIn, 1) = "a" Then
            IsSQLServerDate = False
        End If
    End If

End Function

maybe because the native datatype for SQL is datetime or smalldatetime. which means that you need to pass the Date portion instead of just the time. so instead of placing "10:59a", it should be something like "05/04/2005 10:59am".
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now