Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7671831
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:08:53+00:00 2026-05-31T16:08:53+00:00

I’m using a timespan function to work out the number of days, this value

  • 0

I’m using a timespan function to work out the number of days, this value is then added to a text box and saved to the database.

I have recently added a radio button as a half day so it if is checked it adds 0.5 days holiday rather than 1 day. This seems to work correctly when displayed in the text box before being saved. However, when it actually saves and updates the database shows a value of 1 rather than 0.5 as shown in text box.

The fieldtype in the database for this field was originally set to ‘int’but when I added the half day it would not save as it was trying to save a decimal figure, I have since changed this fieldtype to ‘decimal’ as it thought this would be more suitable.. i’m not sure if this is correct or it should be something different?

I cannot seem to figure out why it is not saving the value specified in the text box…any suggestions

 Private Sub btnHNoDays_Click(sender As Object, e As System.EventArgs) Handles btnHNoDays.Click

    'declare dates
    Dim dtStart As Date = txtHStart_Date.Text
    Dim dtEnd As Date = txtHEnd_Date.Text

    'timespan function used to minus one date to another and produce a value 
    Dim ts As TimeSpan = (dtEnd - dtStart)

    If RadioButton1.Checked Then

        ts = (dtEnd - dtStart) - TimeSpan.FromDays(0.5)
    Else
        ts = (dtEnd - dtStart)
    End If

    ' the value is set to to textbox.
    txtNoofDays.Text = ts.TotalDays()

    ' the today days value
    Console.WriteLine(ts.TotalDays)
End Sub



Protected Sub btnHRequestSave_Click(ByVal sender As Object, ByVal e As EventArgs) Handles btnHRequestSave.Click
    'collect data
    Dim Sdate = txtHStart_Date.Text
    Dim Edate = txtHEnd_Date.Text
    Dim NoofDays = txtNoofDays.Text
    Dim notes = TxtHRequestNotes.Text
    Dim username = lblHolidayRequestLIU.Text

    'define connection

    Dim HRequestConnection As New SqlConnection
    HRequestConnection.ConnectionString = HolidayRequestSqlDataSource.ConnectionString

    'create command
   Dim HRequestInsert As New SqlCommand("Insert into HolidayRequests (username, RequestDateStart, RequestDateEnd, RequestTotalDays, RequestNotes) VALUES (@username, @Sdate, @Edate, @NoofDays, @notes)", HRequestConnection)

    'define parameters
    HRequestInsert.Parameters.Add("username", SqlDbType.NVarChar, 20).Value = lblHolidayRequestLIU.Text
    HRequestInsert.Parameters.Add("Sdate", SqlDbType.Date).Value = txtHStart_Date.Text
    HRequestInsert.Parameters.Add("Edate", SqlDbType.Date).Value = txtHEnd_Date.Text
    HRequestInsert.Parameters.Add("NoofDays", SqlDbType.Decimal).Value = txtNoofDays.Text
    HRequestInsert.Parameters.Add("notes", SqlDbType.NVarChar).Value = TxtHRequestNotes.Text

    ' execute commands
    HRequestConnection.Open()
    HRequestInsert.ExecuteNonQuery()

    lblHolRequestResponse.Text = "Your holidays request has been saved!
End Sub
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T16:08:54+00:00Added an answer on May 31, 2026 at 4:08 pm

    How have you specified the decimal column in the database? Have you given it precision and scale (see here)? If not, it defaults to decimal(18,0) which will give you no figures after the decimal point.

    You should give it a type along the lines of decimal(5,1) depending on your requirements.

    Bear in mind that precision is the number of total digits (to the left and right of the decimal point) and scale is the number to the right of the decimal point. Therefore decimal(5,1) could store up to 9999.9.

    (I’m assuming you’re using SQL Server)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
For some reason, after submitting a string like this Jack’s Spindle from a text
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have a reasonable size flat file database of text documents mostly saved in
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.