2102 Number And Date Fields
Number and Date Fields
Introduction to Number and Date Fields
Number and date fields are essential for tracking quantities, prices, measurements, time, and temporal data. These fields enable calculations, aggregations, comparisons, and time-based operations that text fields simply can't provide. Understanding how to use them properly is crucial for building functional applications.
In this lesson, you'll learn about ten different number and date field types, including specialized fields like currency, auto-increment, ratings, sliders, and various date/time options. Each field type has unique features and configuration options that make it perfect for specific use cases.
Number Field
What is a Number Field?
The Number field stores numeric values and enables mathematical operations. It's the foundation for any calculation, measurement, or quantity tracking in your application.
When to Use Number Fields
Use number fields for:
- Quantities - Inventory counts, order quantities, available seats
- Measurements - Weight, height, distance, volume
- Scores - Test scores, ratings (when not using rating field), points
- Ages - Age in years, months, days
- Counts - Number of employees, items, occurrences
- Non-currency Values - Any numeric data that isn't money
Number Field Features
Number fields provide:
- Mathematical Operations - Add, subtract, multiply, divide
- Aggregations - Sum, average, minimum, maximum
- Comparisons - Greater than, less than, between
- Decimal Support - Configurable decimal places
- Negative Numbers - Allow or disallow negative values
- Formatting - Thousands separators, decimal precision
Configuration Options
Number field configuration includes:
- Decimal Places - 0-10 decimal places (0 = whole numbers only)
- Minimum Value - Lowest allowed value
- Maximum Value - Highest allowed value
- Default Value - Pre-filled value for new records
- Step - Increment/decrement amount (for number spinners)
- Allow Negative - Enable/disable negative numbers
- Thousands Separator - Display commas for large numbers
- Required - Must have a value
Best Practices
Follow these number field best practices:
- Set appropriate decimal places (2 for most measurements, 0 for counts)
- Use minimum value of 0 for quantities that can't be negative
- Set realistic maximum values to prevent data entry errors
- Use thousands separators for better readability of large numbers
- Don't use number fields for phone numbers or ZIP codes (use text/phone fields)
Example Configuration
Inventory Quantity Field:
- Field Name: quantity_in_stock
- Display Name: Quantity in Stock
- Decimal Places: 0
- Minimum Value: 0
- Required: Yes
- Default Value: 0
- Thousands Separator: Yes
Currency Field
What is a Currency Field?
The Currency field is a specialized number field designed for monetary values. It automatically formats values with currency symbols and ensures proper decimal places for financial calculations.
When to Use Currency Fields
Use currency fields for:
- Prices - Product prices, service fees, subscription costs
- Costs - Expenses, operating costs, overhead
- Revenue - Sales amounts, income, earnings
- Budgets - Budget allocations, spending limits
- Financial Calculations - Any monetary value or financial data
Currency Features
Currency fields provide:
- Currency Symbol - Automatic $ (or other currency symbol)
- Two Decimal Places - Standard for currency (configurable)
- Thousands Separators - Commas for readability ($1,000.00)
- Multi-Currency Support - Different currencies (USD, EUR, GBP, etc.)
- Financial Calculations - Precise math for money
- Proper Formatting - Always displays correctly formatted amounts
Configuration Options
Currency field configuration:
- Currency Type - USD, EUR, GBP, JPY, etc.
- Decimal Places - Usually 2 (can adjust for specific currencies)
- Minimum Value - Lowest allowed amount
- Maximum Value - Highest allowed amount
- Default Value - Pre-filled amount
- Required - Must have a value
- Allow Negative - For refunds, discounts, adjustments
Currency vs Number
Always use Currency field instead of Number field for money because:
- Automatic currency symbol and formatting
- Proper decimal precision for financial calculations
- Better display in tables and forms
- Clear indication that value represents money
- Support for multiple currencies
Example Configuration
Product Price Field:
- Field Name: price
- Display Name: Price
- Currency Type: USD
- Decimal Places: 2
- Minimum Value: 0.01
- Required: Yes
- Allow Negative: No
Auto-Increment Field
What is an Auto-Increment Field?
The Auto-Increment field automatically generates sequential numbers for each new record. It's perfect for creating unique identifiers like invoice numbers, order numbers, or customer IDs.
When to Use Auto-Increment Fields
Use auto-increment fields for:
- Invoice Numbers - INV-001, INV-002, INV-003
- Order Numbers - Sequential order tracking
- Customer IDs - Unique customer identifiers
- Ticket Numbers - Support ticket numbering
- Reference Numbers - Any sequential identifier
Auto-Increment Features
Auto-increment fields offer:
- Automatic Generation - No manual entry needed
- Sequential Numbering - 1, 2, 3... or custom sequences
- Unique Values - Never duplicates
- Prefix/Suffix Support - INV-001, ORD-2024-001
- Leading Zeros - 001, 002, 003 (padding)
- Starting Value - Begin at any number
Configuration Options
Auto-increment configuration:
- Prefix - Text before number (INV-, ORD-, CUST-)
- Starting Number - First number in sequence (default 1)
- Increment By - How much to increase (usually 1)
- Number of Digits - Padding with zeros (3 = 001, 4 = 0001)
- Suffix - Text after number (-2024)
- Preview - Shows next generated number
Best Practices
Auto-increment best practices:
- Use meaningful prefixes (INV for invoices, ORD for orders)
- Add enough padding digits for expected volume (1000 records = 4 digits)
- Don't reset or change once in production (breaks references)
- Consider year in suffix for annual resets (ORD-2024-001)
- Set starting number if migrating from another system
Example Configuration
Invoice Number Field:
- Field Name: invoice_number
- Display Name: Invoice #
- Prefix: INV-
- Starting Number: 1000
- Number of Digits: 5
- Result: INV-01000, INV-01001, INV-01002...
Rating Field
What is a Rating Field?
The Rating field displays as stars, hearts, or other icons that users can click to provide a rating. It's a visual, user-friendly way to capture ratings and scores.
When to Use Rating Fields
Use rating fields for:
- Product Reviews - Customer product ratings
- Service Quality - Service rating and feedback
- Performance Reviews - Employee performance ratings
- Content Ratings - Article, video, course ratings
- Satisfaction Scores - Customer satisfaction (CSAT)
- Priority Levels - Visual priority indicators
Rating Features
Rating fields provide:
- Visual Display - Stars, hearts, thumbs, custom icons
- Click to Rate - Easy user interaction
- Customizable Scale - 5-star, 10-star, or any scale
- Half-Star Support - Allow half ratings (3.5 stars)
- Color Customization - Active and inactive colors
- Calculations - Average ratings, rating counts
Configuration Options
Rating field configuration:
- Icon Type - Stars, hearts, thumbs, circles, custom
- Maximum Rating - 5, 10, or custom number
- Allow Half Values - Enable/disable half ratings
- Active Color - Color for selected icons
- Inactive Color - Color for unselected icons
- Size - Small, medium, large
- Required - Must provide rating
Example Configuration
Product Rating Field:
- Field Name: product_rating
- Display Name: Rating
- Icon Type: Stars
- Maximum Rating: 5
- Allow Half Values: Yes
- Active Color: Gold
- Required: No
Slider Field
What is a Slider Field?
The Slider field displays as a horizontal slider that users drag to select a value within a defined range. It's perfect for visual selection of values along a continuum.
When to Use Slider Fields
Use slider fields for:
- Range Selection - Price ranges, age ranges, size ranges
- Satisfaction Levels - 0-100 satisfaction scores
- Volume/Intensity - Volume levels, brightness, intensity
- Percentages - Completion percentage, discount percentage
- Scale Values - Any value that fits a visual scale
Slider Features
Slider fields offer:
- Visual Selection - Drag to select value
- Range Definition - Set minimum and maximum values
- Step Increments - Control precision (1, 5, 10, 0.1, etc.)
- Real-time Display - Show current value as user drags
- Labels - Display min/max/current values
Configuration Options
Slider field configuration:
- Minimum Value - Lowest selectable value
- Maximum Value - Highest selectable value
- Step - Increment amount (1, 5, 10, 0.5, etc.)
- Default Value - Starting position
- Show Value - Display current value
- Show Labels - Display min/max labels
- Color - Slider color
Example Configuration
Satisfaction Score Field:
- Field Name: satisfaction_score
- Display Name: Satisfaction Level
- Minimum Value: 0
- Maximum Value: 100
- Step: 5
- Default Value: 50
- Show Value: Yes
Date Field
What is a Date Field?
The Date field stores calendar dates (day, month, year) without time information. It provides a date picker for easy date selection and enables date-based filtering and calculations.
When to Use Date Fields
Use date fields for:
- Birth Dates - Date of birth, anniversary dates
- Due Dates - Task due dates, payment due dates
- Start/End Dates - Project start, contract end
- Event Dates - Event, meeting, appointment dates
- Historical Dates - Hire date, registration date
- Deadlines - Submission deadlines, expiration dates
Date Field Features
Date fields provide:
- Calendar Picker - Visual date selection
- Date Validation - Ensures valid dates only
- Date Formatting - MM/DD/YYYY, DD/MM/YYYY, etc.
- Date Calculations - Days between, add/subtract days
- Date Filtering - Before, after, between dates
- Relative Dates - Today, yesterday, last week
Configuration Options
Date field configuration:
- Date Format - Display format (MM/DD/YYYY, DD/MM/YYYY, YYYY-MM-DD)
- Default Value - Today, specific date, or empty
- Minimum Date - Earliest selectable date
- Maximum Date - Latest selectable date
- Required - Must have a value
- Calendar Start Day - Sunday or Monday
- Disable Dates - Block specific dates or date ranges
Best Practices
Date field best practices:
- Use consistent date format across your application
- Set default to "Today" for current date fields
- Use minimum date to prevent past dates when needed
- Consider time zones for date-only fields (usually not an issue)
- Use Date field (not DateTime) when time doesn't matter
Example Configuration
Due Date Field:
- Field Name: due_date
- Display Name: Due Date
- Date Format: MM/DD/YYYY
- Default Value: None
- Minimum Date: Today
- Required: Yes
Time Field
What is a Time Field?
The Time field stores time of day (hours and minutes) without date information. It's perfect for scheduling, time tracking, and time-based operations.
When to Use Time Fields
Use time fields for:
- Business Hours - Opening time, closing time
- Schedules - Class times, shift times
- Appointments - Appointment times (when date is separate)
- Time Tracking - Clock in/out times
- Duration - Length of time (though duration field is better)
Time Field Features
Time fields provide:
- Time Picker - Visual time selection
- 12/24 Hour Format - AM/PM or 24-hour time
- Time Validation - Ensures valid times
- Time Calculations - Time differences, add/subtract time
- Time Filtering - Before, after, between times
Configuration Options
Time field configuration:
- Time Format - 12-hour (AM/PM) or 24-hour
- Minute Interval - 1, 5, 10, 15, 30 minutes
- Default Value - Current time, specific time, or empty
- Minimum Time - Earliest selectable time
- Maximum Time - Latest selectable time
- Required - Must have a value
Example Configuration
Appointment Time Field:
- Field Name: appointment_time
- Display Name: Time
- Time Format: 12-hour (AM/PM)
- Minute Interval: 15
- Minimum Time: 8:00 AM
- Maximum Time: 5:00 PM
- Required: Yes
DateTime Field
What is a DateTime Field?
The DateTime field stores both date and time together in a single field. It's essential for timestamping events, logging activities, and scheduling specific moments in time.
When to Use DateTime Fields
Use datetime fields for:
- Appointments - Specific date and time
- Events - Event start/end date and time
- Logs - Activity logs, audit trails
- Timestamps - When something happened (created, modified)
- Deadlines with Time - Exact deadline including time
- Meetings - Meeting date and time
DateTime Features
DateTime fields provide:
- Combined Picker - Select date and time together
- Time Zone Support - Handle different time zones
- Precise Timestamps - Exact moment in time
- Date/Time Calculations - Full date and time math
- Flexible Formatting - Display in various formats
Configuration Options
DateTime field configuration:
- Date Format - How date displays
- Time Format - 12-hour or 24-hour
- Time Zone - User's time zone, specific time zone, UTC
- Default Value - Current date/time, specific date/time, or empty
- Minimum DateTime - Earliest selectable date/time
- Maximum DateTime - Latest selectable date/time
- Required - Must have a value
Time Zone Considerations
When using DateTime fields:
- Consider if users are in different time zones
- Decide: display in user's time zone or specific time zone
- Use UTC for internal storage, convert for display
- Be clear about time zone in field label
Example Configuration
Meeting DateTime Field:
- Field Name: meeting_datetime
- Display Name: Meeting Date & Time
- Date Format: MM/DD/YYYY
- Time Format: 12-hour
- Time Zone: User's time zone
- Required: Yes
Date Range Field
What is a Date Range Field?
The Date Range field stores a start date and end date together, representing a period of time. It's perfect for tracking durations and date spans.
When to Use Date Range Fields
Use date range fields for:
- Project Duration - Project start and end dates
- Employment Period - Hire date to termination/current
- Events - Multi-day events with start and end
- Contracts - Contract effective dates
- Vacations - Time off requests
- Promotions - Promotional period dates
Date Range Features
Date range fields provide:
- Single Field Input - Select both dates in one picker
- Visual Range Selection - Highlight date range on calendar
- Duration Calculation - Automatic calculation of days between
- Validation - End date must be after start date
- Overlap Detection - Check for date range overlaps
Configuration Options
Date range field configuration:
- Date Format - How dates display
- Default Values - Default start/end dates
- Minimum Start Date - Earliest start date
- Maximum End Date - Latest end date
- Show Duration - Display number of days
- Required - Both dates required
Example Configuration
Project Dates Field:
- Field Name: project_dates
- Display Name: Project Duration
- Date Format: MM/DD/YYYY
- Show Duration: Yes
- Required: Yes
Percentage Field
What is a Percentage Field?
The Percentage field is a specialized number field that displays values with a % symbol. It's designed specifically for percentage values.
When to Use Percentage Fields
Use percentage fields for:
- Completion - Task completion percentage
- Discounts - Discount percentages
- Commission - Commission rates
- Tax Rates - Sales tax, VAT percentages
- Growth Rates - Percentage increase/decrease
- Probabilities - Likelihood percentages
Configuration Options
Percentage field configuration:
- Decimal Places - Precision (0-10 decimals)
- Minimum Value - Lowest allowed percentage
- Maximum Value - Highest allowed percentage (usually 100)
- Default Value - Pre-filled percentage
- Allow Over 100 - Enable percentages over 100%
- Required - Must have a value
Example Configuration
Discount Percentage Field:
- Field Name: discount_percentage
- Display Name: Discount %
- Decimal Places: 2
- Minimum Value: 0
- Maximum Value: 100
- Default Value: 0
- Required: No
Choosing the Right Number/Date Field
Use this decision guide:
| Data Type | Field Type | Why |
| Quantity | Number | Simple numeric value |
| Price | Currency | Monetary value, currency symbol |
| Invoice number | Auto-Increment | Sequential unique identifier |
| Product rating | Rating | Visual star rating |
| Satisfaction score | Slider | Visual range selection |
| Birth date | Date | Date only, no time |
| Opening time | Time | Time only, no date |
| Appointment | DateTime | Specific date and time |
| Project duration | Date Range | Start and end dates |
| Discount | Percentage | Percentage value with % |
Hands-On Practice
Practice with number and date fields:
Exercise 1: Create Product Table
- Create a new table named "Products"
- Add these fields:
- Product ID (Auto-Increment) - Prefix: PROD-, 4 digits
- Product Name (Text) - Required
- Price (Currency) - USD, required, minimum $0.01
- Cost (Currency) - USD, not required
- Quantity in Stock (Number) - 0 decimals, minimum 0
- Weight (Number) - 2 decimals (pounds)
- Customer Rating (Rating) - 5 stars, half values allowed
- Discount Percentage (Percentage) - 0-100, default 0
- Manufactured Date (Date) - Not required
- Availability Period (Date Range) - Start and end dates
- Add at least 5 product records
- Test each field type with different values
Exercise 2: Create Event Table
- Create a table named "Events"
- Add these fields:
- Event Number (Auto-Increment) - Prefix: EVT-
- Event Name (Text) - Required
- Event Date (DateTime) - Required, future dates only
- Ticket Price (Currency) - Required
- Capacity (Number) - Whole numbers, minimum 1
- Satisfaction Goal (Slider) - 0-100, step 5
- Event Duration (Date Range) - Multi-day events
- Create sample events
- Practice date/time selection
Exercise 3: Test Calculations
- In Products table, observe auto-increment numbering
- Enter different quantities and see number formatting
- Try entering invalid values (negative numbers where not allowed)
- Test date range validation (end before start)
- Experiment with rating and slider interactions
Real-World Examples
Real-world applications:
E-Commerce Platform
- Auto-Increment - Order numbers (ORD-00001)
- Currency - Product price, shipping cost, tax amount
- Number - Quantity in stock, quantity ordered
- Percentage - Discount percentage, commission rate
- Rating - Product reviews and ratings
- Date - Expected delivery date
- DateTime - Order placed timestamp
Project Management
- Auto-Increment - Task ID, project number
- Date Range - Project duration, sprint dates
- Number - Estimated hours, actual hours
- Percentage - Completion percentage
- Slider - Priority level (1-10)
- Currency - Budget, actual cost
- DateTime - Task deadline
Employee Management
- Auto-Increment - Employee ID
- Date - Hire date, birth date
- Date Range - Time off requests
- Currency - Salary, bonus
- Rating - Performance rating
- Time - Shift start/end times
- Number - Years of experience
Common Mistakes
Avoid these mistakes:
- Using Number for Money - Always use Currency field for monetary values
- Wrong Decimal Places - Set appropriate precision (0 for counts, 2 for measurements)
- Not Setting Min/Max - Prevent invalid data with proper constraints
- DateTime for Date-Only - Use Date field when time doesn't matter
- Separate Start/End Dates - Use Date Range for periods instead of two date fields
- Manual Sequential Numbers - Use Auto-Increment instead of expecting users to enter sequential IDs
- Wrong Time Format - Match time format to user expectations (12-hour for most US users)
Summary
You've learned about ten number and date field types:
- Number - Basic numeric values for quantities and measurements
- Currency - Monetary values with currency symbols
- Auto-Increment - Automatic sequential numbering
- Rating - Visual star ratings
- Slider - Visual range selection
- Date - Calendar dates without time
- Time - Time of day without date
- DateTime - Date and time together
- Date Range - Start and end dates
- Percentage - Percentage values with % symbol
Checklist
Before continuing, ensure you can:
- Choose appropriate number field type for any numeric data
- Configure decimal places, min/max values for number fields
- Set up currency fields with proper currency type
- Create auto-increment fields with prefixes and padding
- Add rating and slider fields for visual input
- Configure date fields with proper formats and constraints
- Understand when to use Date vs DateTime vs Date Range
- Set up time fields for time-of-day values
- Apply best practices for all number and date fields
Next Steps
Next, you'll learn about option and document fields including dropdowns, checkboxes, radio buttons, and file upload fields.
Next: Option and Document Fields - Choice fields and file handling
Knowledge Check (To Be Added)
Quiz will cover:
- Choosing between Number, Currency, and Percentage
- When to use Auto-Increment fields
- Configuring decimal places appropriately
- Date vs DateTime vs Date Range use cases
- Time field configuration
- Rating vs Slider field selection
We'd love to hear your feedback.